package com.netease.worldcuplive;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
import android.view.View;
import android.widget.Toast;

import com.avos.avoscloud.AVOSCloud;
import com.netease.worldcuplive.fragment.GameFragment;
import com.netease.worldcuplive.fragment.RankingsFragment;
import com.netease.worldcuplive.fragment.ScheduleFragment;
import com.netease.worldcuplive.fragment.VideoFragment;
import com.netease.worldcuplive.listener.NsFragmentTabHost;
import com.netease.worldcuplive.listener.NsFragmentTabHost.NsFragmentItem;
import com.netease.worldcuplive.utils.NetWorkChecker;

/**
 * @author Atlantis Ho      email: hunterhbb@gmail.com
 * @version 创建时间: 2014年5月7日 上午10:01:38
 * 类说明:
 */

public class HomeActivity extends FragmentActivity{

	private static final String TAG_VIDEO = "video";
	private static final String TAG_GAME = "game";
	private static final String TAG_SCHEDULE = "schedule";
	private static final String TAG_RANKINGS = "rankings";
	
	
	private NsFragmentTabHost nsTabHost;
	private FragmentTabHost tabHost;
	
//	private static TextView home_title;
	
//	private Button settings;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
//		requestWindowFeature(Window.FEATURE_NO_TITLE);
		//测试用key
//		AVOSCloud.initialize(this, "o1x1krpc8bj0zzs7ty3ckspsnjmstf39yejw2ku9iw1s484i", "ryb6zbtl26pk7kf7hwra73ddbxtcevp7vc722odqvdlk8ja0");
		
		AVOSCloud.initialize(this, "vihv8ophnqy74k5tg1s1asbilkox1ydk3cx7ifjqlhkutnjp", "kqd9jopm5b4rb5pglq3makbh6p7iygpdr1ncnmyojedimos0");
		setContentView(R.layout.activity_home);
		
		tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
		nsTabHost = new NsFragmentTabHost(tabHost, this, R.id.realtabcontent);
		
		View v_video = nsTabHost.newTabView(R.layout.home_tab,  "视频", R.drawable.icon_nav_video);
		View v_game = nsTabHost.newTabView(R.layout.home_tab,  "比赛", R.drawable.icon_nav_match);
		View v_schedule = nsTabHost.newTabView(R.layout.home_tab,  "赛程", R.drawable.icon_nav_schedule);
		View v_rankings = nsTabHost.newTabView(R.layout.home_tab,  "榜单", R.drawable.icon_nav_board);
		
		NsFragmentItem item_video = new NsFragmentItem();
		item_video.view = v_video;
		item_video.tag = TAG_VIDEO;
		item_video.fragment = VideoFragment.class;
		item_video.downStyle = R.drawable.icon_nav_video_actived;
		item_video.upStyle = R.drawable.icon_nav_video;
//		item_video.title = R.string.video;

		NsFragmentItem item_game = new NsFragmentItem();
		item_game.view = v_game;
		item_game.tag = TAG_GAME;
		item_game.fragment = GameFragment.class;
		item_game.downStyle = R.drawable.icon_nav_match_actived;
		item_game.upStyle = R.drawable.icon_nav_match;
//		item_game.title = R.string.game;

		NsFragmentItem item_schedule = new NsFragmentItem();
		item_schedule.view = v_schedule;
		item_schedule.tag = TAG_SCHEDULE;
		item_schedule.fragment = ScheduleFragment.class;
		item_schedule.downStyle = R.drawable.icon_nav_schedule_actived;
		item_schedule.upStyle = R.drawable.icon_nav_schedule;
//		item_schedule.title = R.string.schedule;

		NsFragmentItem item_rankings = new NsFragmentItem();
		item_rankings.view = v_rankings;
		item_rankings.tag =TAG_RANKINGS;
		item_rankings.fragment = RankingsFragment.class;
		item_rankings.downStyle = R.drawable.icon_nav_board_actived;
		item_rankings.upStyle = R.drawable.icon_nav_board;
//		item_rankings.title = R.string.rankings;

		nsTabHost.addTab(item_video);
		nsTabHost.addTab(item_game);
		nsTabHost.addTab(item_schedule);
		nsTabHost.addTab(item_rankings);
		
		
		if( ! NetWorkChecker.isNetWorkOpen(this)){
			Toast.makeText(this, R.string.please_open_network, Toast.LENGTH_SHORT).show();
		}
	}
	
}
